<!DOCTYPE html>
<html>

<head>
    <title>我的消息</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/plugins/bootstrap-4.1.1-dist/css/bootstrap.min.css">
    <script src="/js/plugins/jquery/jquery.min.js"></script>
    <script src="/js/plugins/bootstrap-4.1.1-dist/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/message.css"/>
    <script src="/js/plugins/jrender/jrender.min.js"></script>

    <script>
        $(function () {
            //获取当前登录用户的(session)信息
            var user = JSON.parse(sessionStorage.getItem("user"));
            //页面加载发送ajax 获取未读的 评论数量
            $.get('/users/' + user.id + '/countUnReadSystemMessages', function (data) {
                console.log(data);
                if (data.result > 0) {
                    $("#system").renderValues(data)
                }
            })
            //页面加载发送ajax 获取未读的 信息数量
            $.get('/users/' + user.id + '/countUnReadletters', function (data) {
                console.log(data);
                if (data.result > 0) {
                    $("#letter").renderValues(data)
                }
            })
            //页面加载发送ajax 获取未读的 点赞的游记
            $.get('/users/' + user.id + '/countUnReadLikes', function (data) {
                console.log(data);
                if (data.result > 0) {
                    $("#like").renderValues(data)
                }
            })
            //页面加载发送ajax 获取未读的 评论的游记
            $.get('/users/' + user.id + '/countUnReadcomment', function (data) {
                console.log(data);
                if (data.result > 0) {
                    $("#comment").renderValues(data)
                }
            })
            $('#like').click(function () {
                var href = $(this).data('href');
                //发送修改状态为已读
                $.ajax({
                    url: '/likes',
                    data: "authorId=" + user.id,
                    type: 'put',
                    success: function () {
                        //跳转到具体点赞列表
                        window.location.href = href;
                    }
                });
                //去掉样式
                $(this).find('.badge').html('');
            })
            $('#comment').click(function () {
                var href = $(this).data('href');
                //发送修改状态为已读
                $.ajax({
                    url: '/travelComments',
                    data: "authorId=" + user.id,
                    type: 'put',
                    success: function () {
                        //跳转到具体点赞列表
                        window.location.href = href;
                    }
                });
                //去掉样式
                $(this).find('.badge').html('');
            })
        })
    </script>
</head>

<body>
<div class="search-head">
    <div class="row nav-search">
        <div class="col">
            <a href="javascript:history.go(-1);">
                <span><i class="fa fa-chevron-left"></i></span>
            </a>
        </div>
        <div class="col">
            <span>我的消息</span>
        </div>
        <div class="col"></div>
    </div>
</div>

		<ul class="list-group">
			<a data-href="/mine/like.html" id="like">
				<li class="list-group-item d-flex justify-content-between align-items-center">
					<div class="item">
						<span><i class="fa fa-thumbs-o-up" ></i></span>
						<span>赞</span>
						<span class="badge badge-danger badge-pill"   render-html="result"></span>
					</div>
					<i class="fa fa-chevron-right"></i>
				</li>
			</a>
		<!--	<a data-href="../index.html">
				<li class="list-group-item d-flex justify-content-between align-items-center">
					<div class="item">
						<span><i class="fa fa-at" ></i></span>
						<span>@我的</span>
						<span class="badge badge-danger badge-pill">2</span>
					</div>
					<i class="fa fa-chevron-right"></i>
				</li>
			</a>-->
			<a href="/mine/comment.html" id="comment">
				<li class="list-group-item d-flex justify-content-between align-items-center">
					<div class="item">
						<span><i class="fa fa-commenting-o" ></i>	</span>
						<span>评论</span>
						<span class="badge badge-danger badge-pill"  render-html="result"></span>
					</div>
					<i class="fa fa-chevron-right"></i>
				</li>
			</a>
			<a href="/mine/letter.html" id="letter">
				<li class="list-group-item d-flex justify-content-between align-items-center">
					<div class="item">
						<span><i class="fa fa-envelope-o" ></i></span>
						<span>	私信</span>
						<span class="badge badge-danger badge-pill" render-html="result"></span>
					</div>
					<i class="fa fa-chevron-right"></i>
				</li>
			</a>
			<a href="/mine/SystemMsg.html" id="system">
				<li class="list-group-item d-flex justify-content-between align-items-center">
					<div class="item">
						<span><i class="fa fa-bell" ></i></span>
						<span>系统通知</span>
						<span class="badge badge-danger badge-pill" render-html="result"></span>
					</div>
					<i class="fa fa-chevron-right"></i>
				</li>
			</a>
		</ul>

			<!--<div class="container systemMsg">
					<dl class="itemList">
						<dd>
							<p>如果你无法简洁的表达你的想法，那只说明你还不够了解它。</p>
							<p>&#45;&#45; 阿尔伯特·爱因斯坦</p>
							<p>32分钟前</p>
						</dd>

					</dl>
				</div>-->

</body>

</html>